﻿using System;
using System.IO;

using LazyLib.Helpers;
using Frosty.Helpers;


namespace Frosty.Conf
{
    public class Ini
    {
        public static IniManager IniManager;

        public static void SaveValues()
        {

            IniManager.IniWriteValue("Talents", "TalentSpec", (int)ConfigValues.Spec + "");
            IniManager.IniWriteValue("Presence", "WhatPresence", (int)ConfigValues.Presence + "");

            IniManager.IniWriteValue("Glyph", "HowlingBlastGlyph", ConfigValues.BuffPrePull.ToString());

            IniManager.IniWriteValue("BuffSettings", "BuffPrePull", ConfigValues.BuffPrePull.ToString());
            IniManager.IniWriteValue("BuffSettings", "BuffInPull", ConfigValues.BuffInPull.ToString());
            IniManager.IniWriteValue("BuffSettings", "BuffInCombat", ConfigValues.BuffInCombat.ToString());

            IniManager.IniWriteValue("HealAbilities", "RuneTapPercent", ConfigValues.RuneTapPercent.ToString());
            IniManager.IniWriteValue("HealAbilities", "DeathStrikePercent", ConfigValues.DeathStrikePercent.ToString());
            IniManager.IniWriteValue("HealAbilities", "RuneTap", ConfigValues.RuneTap.ToString());

            IniManager.IniWriteValue("SurvivalAbilities", "IBFPercent", ConfigValues.IBFPercent.ToString());
            IniManager.IniWriteValue("SurvivalAbilities", "IBF", ConfigValues.IBF.ToString());
            IniManager.IniWriteValue("SurvivalAbilities", "AMS", ConfigValues.AMS.ToString());
            IniManager.IniWriteValue("SurvivalAbilities", "BoneShield", ConfigValues.BoneShield.ToString());
            IniManager.IniWriteValue("SurvivalAbilities", "HungeringCold", ConfigValues.HungeringCold.ToString());
            IniManager.IniWriteValue("SurvivalAbilities", "VampiricBlood", ConfigValues.VampiricBlood.ToString());

            IniManager.IniWriteValue("PullAbilities", "DarkCommand", ConfigValues.DarkCommand.ToString());
            IniManager.IniWriteValue("PullAbilities", "DeathGrip", ConfigValues.DeathGrip.ToString());

            IniManager.IniWriteValue("BuffAbilities", "HornofWinter", ConfigValues.HornofWinter.ToString());
            IniManager.IniWriteValue("BuffAbilities", "PillarofFrost", ConfigValues.PillarofFrost.ToString());
            IniManager.IniWriteValue("BuffAbilities", "UnholyFrenzy", ConfigValues.UnholyFrenzy.ToString());

            IniManager.IniWriteValue("DiseaseAbilities", "IcyTouch", ConfigValues.IcyTouch.ToString());
            IniManager.IniWriteValue("DiseaseAbilities", "PlagueStrike", ConfigValues.PlagueStrike.ToString());
            IniManager.IniWriteValue("DiseaseAbilities", "Outbreak", ConfigValues.Outbreak.ToString());

            IniManager.IniWriteValue("InterruptAbilities", "MindFreeze", ConfigValues.MindFreeze.ToString());
            IniManager.IniWriteValue("InterruptAbilities", "Strangulate", ConfigValues.Strangulate.ToString());

            IniManager.IniWriteValue("DamageAbilities", "BloodStrike", ConfigValues.BloodStrike.ToString());
            IniManager.IniWriteValue("DamageAbilities", "DarkTransformation", ConfigValues.DarkTransformation.ToString());
            IniManager.IniWriteValue("DamageAbilities", "DeathCoil", ConfigValues.DeathCoil.ToString());
            IniManager.IniWriteValue("DamageAbilities", "DeathStrike", ConfigValues.DeathStrike.ToString());
            IniManager.IniWriteValue("DamageAbilities", "ERW", ConfigValues.ERW.ToString());
            IniManager.IniWriteValue("DamageAbilities", "BloodTap", ConfigValues.BloodTap.ToString());
            IniManager.IniWriteValue("DamageAbilities", "FesteringStrike", ConfigValues.FesteringStrike.ToString());
            IniManager.IniWriteValue("DamageAbilities", "FrostStrike", ConfigValues.FrostStrike.ToString());
            IniManager.IniWriteValue("DamageAbilities", "HeartStrike", ConfigValues.HeartStrike.ToString());
            IniManager.IniWriteValue("DamageAbilities", "HowlingBlast", ConfigValues.HowlingBlast.ToString());
            IniManager.IniWriteValue("DamageAbilities", "Obliterate", ConfigValues.Obliterate.ToString());
            IniManager.IniWriteValue("DamageAbilities", "Pestilence", ConfigValues.Pestilence.ToString());
            IniManager.IniWriteValue("DamageAbilities", "RaiseDead", ConfigValues.RaiseDead.ToString());
            IniManager.IniWriteValue("DamageAbilities", "RuneStrike", ConfigValues.RuneStrike.ToString());
            IniManager.IniWriteValue("DamageAbilities", "ScourgeStrike", ConfigValues.ScourgeStrike.ToString());
            IniManager.IniWriteValue("DamageAbilities", "SummonGargoyle", ConfigValues.SummonGargoyle.ToString());
            IniManager.IniWriteValue("DamageAbilities", "DeathAndDecay", ConfigValues.DeathAndDecay.ToString());
            

        }

        public static void LoadValues()
        {
            ConfigValues.Spec = (Spec)IniManager.GetInt("Talents", "TalentSpec", 2);
            ConfigValues.Presence = (Presence)IniManager.GetInt("Presence", "WhatPresence", 3);

            ConfigValues.HowlingBlastGlyph = IniManager.GetBoolean("Glyph", "HowlingBlastGlyph", true);

            ConfigValues.RuneTapPercent = IniManager.GetInt("HealAbilities", "RuneTapPercent", 75);
            ConfigValues.DeathStrikePercent = IniManager.GetInt("HealAbilities", "DeathStrikePercent", 75);
            ConfigValues.RuneTap = IniManager.GetBoolean("HealAbilities", "RuneTap", true);

            ConfigValues.IBFPercent = IniManager.GetInt("SurvivalAbilities", "IBFPercent", 75);
            ConfigValues.IBF = IniManager.GetBoolean("SurvivalAbilities", "IBF", true);
            ConfigValues.AMS = IniManager.GetBoolean("SurvivalAbilities", "AMS", true);
            ConfigValues.BoneShield = IniManager.GetBoolean("SurvivalAbilities", "BoneShield", true);
            ConfigValues.HungeringCold = IniManager.GetBoolean("SurvivalAbilities", "HungeringCold", true);
            ConfigValues.VampiricBlood = IniManager.GetBoolean("SurvivalAbilities", "VampiricBlood", true);

            ConfigValues.DarkCommand = IniManager.GetBoolean("PullAbilities", "DarkCommand", true);
            ConfigValues.DeathGrip = IniManager.GetBoolean("PullAbilities", "DeathGrip", true);

            ConfigValues.HornofWinter = IniManager.GetBoolean("BuffAbilities", "HornofWinter", true);
            ConfigValues.PillarofFrost = IniManager.GetBoolean("BuffAbilities", "PillarofFrost", true);
            ConfigValues.UnholyFrenzy = IniManager.GetBoolean("BuffAbilities", "UnholyFrenzy", true);

            ConfigValues.BuffPrePull = IniManager.GetBoolean("BuffSettings", "BuffPrePull", true);
            ConfigValues.BuffInPull = IniManager.GetBoolean("BuffSettings", "BuffInPull", true);
            ConfigValues.BuffInCombat = IniManager.GetBoolean("BuffSettings", "BuffInCombat", true);

            ConfigValues.IcyTouch = IniManager.GetBoolean("DiseaseAbilities", "IcyTouch", true);
            ConfigValues.PlagueStrike = IniManager.GetBoolean("DiseaseAbilities", "PlagueStrike", true);
            ConfigValues.Outbreak = IniManager.GetBoolean("DiseaseAbilities", "Outbreak", true);

            ConfigValues.MindFreeze = IniManager.GetBoolean("InterruptAbilities", "MindFreeze", true);
            ConfigValues.Strangulate = IniManager.GetBoolean("InterruptAbilities", "Strangulate", true);

            ConfigValues.BloodStrike = IniManager.GetBoolean("DamageAbilities", "BloodStrike", true);
            ConfigValues.DarkTransformation = IniManager.GetBoolean("DamageAbilities", "DarkTransformation", true);
            ConfigValues.DeathCoil = IniManager.GetBoolean("DamageAbilities", "DeathCoil", true);
            ConfigValues.DeathStrike = IniManager.GetBoolean("DamageAbilities", "DeathStrike", true);
            ConfigValues.ERW = IniManager.GetBoolean("DamageAbilities", "ERW", true);
            ConfigValues.BloodTap = IniManager.GetBoolean("DamageAbilities", "BloodTap", true);
            ConfigValues.FesteringStrike = IniManager.GetBoolean("DamageAbilities", "FesteringStrike", true);
            ConfigValues.FrostStrike = IniManager.GetBoolean("DamageAbilities", "FrostStrike", true);
            ConfigValues.HeartStrike = IniManager.GetBoolean("DamageAbilities", "HeartStrike", true);
            ConfigValues.HowlingBlast = IniManager.GetBoolean("DamageAbilities", "HowlingBlast", true);
            ConfigValues.Obliterate = IniManager.GetBoolean("DamageAbilities", "Obliterate", true);
            ConfigValues.Pestilence = IniManager.GetBoolean("DamageAbilities", "Pestilence", true);
            ConfigValues.RaiseDead = IniManager.GetBoolean("DamageAbilities", "RaiseDead", true);
            ConfigValues.RuneStrike = IniManager.GetBoolean("DamageAbilities", "RuneStrike", true);
            ConfigValues.ScourgeStrike = IniManager.GetBoolean("DamageAbilities", "ScourgeStrike", true);
            ConfigValues.SummonGargoyle = IniManager.GetBoolean("DamageAbilities", "SummonGargoyle", true);
            ConfigValues.DeathAndDecay = IniManager.GetBoolean("DamageAbilities", "DeathAndDecay", true);
            

        }

        public static void Initialize()
        {
            IniManager = new IniManager(AppDomain.CurrentDomain.BaseDirectory + @"Settings\Frosty.ini");
            if (!File.Exists(IniManager.FilePath))
            {
                SaveValues();
            }
            LoadValues();
        }
    }
}
